//
//  HHContractDetailViewController.m
//  HHBroker
//
//  Created by He Wei on 9/27/15.
//  Copyright © 2015 harry. All rights reserved.
//

#import "HHContractDetailViewController.h"
#import "HHContractDetailReformer.h"

@interface HHContractDetailViewController ()

@end

@implementation HHContractDetailViewController

#pragma mark - DeInit

- (void)dealloc
{
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Life Cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    [self prepareData];
}

#pragma mark - Delegate
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *reuseCell = @"reuseCell";
    
    if (indexPath.section == 0) {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseCell];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseCell];
        cell.textLabel.textColor = UIColorFromRGB(0x999999);
        cell.textLabel.font = [UIFont systemFontOfSize:13];
        cell.detailTextLabel.textColor = UIColorFromRGB(0x5d5d5d);
        cell.detailTextLabel.font = [UIFont systemFontOfSize:13];
    }
    NSDictionary *dic = self.dataArray[indexPath.row];
    cell.textLabel.text = [dic objectForKey:@"title"];
    cell.detailTextLabel.text = [dic objectForKey:@"value"];
    return cell;
    }
    return nil;
}

#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 44.0f;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01f;
}


#pragma mark - Event Response

#pragma mark - Setter && Getter

- (void)prepareData
{
    NSDictionary *response = [self.model dictionaryWithValuesForKeys:@[@"percentage", @"servicetype", @"con_id", @"true_name"]];
    NSArray *array = [HHContractDetailReformer reformDataWithRespone:response];
    [self.dataArray addObjectsFromArray:array];
    [self.tableView reloadData];


}
@end
